package com.zhong.gang.app.ui.zhongzhuan;

import android.app.Activity;
import android.text.TextUtils;

import com.zhong.gang.app.api.Api;
import com.zhong.gang.app.api.HttpUtils;
import com.zhong.gang.applib.http.BaseDataBean;
import com.zhong.gang.applib.http.builder.PostFormBuilder;
import com.zhong.gang.applib.http.callback.Callback;
import com.zhong.gang.applib.http.callback.DataCallBack;

public class ZhongZhuanPersenter {
    private Activity activity;
    public ZhongZhuanPersenter(Activity activity) {
        this.activity = activity;
    }

    /**
     * 获取详情
     * @param id
     * @param callback
     */
    public void getDetail(int id, Callback callback){
        HttpUtils.get(Api.transferDetail,activity)
                .addParams("orderId",id+"")
                .build().execute(callback);
    }

    /**
     * 中转收货
     */
    public void sureDone(Activity activity,int id,String photo){
        PostFormBuilder builder = HttpUtils.post(Api.transferReceive,activity)
                .addParams("orderId",id+"");
        if (!TextUtils.isEmpty(photo))
            builder.addParams("photo",photo);
                builder.build().execute(new DataCallBack<BaseDataBean<String>>(activity) {
            @Override
            public void onResponse(BaseDataBean<String> data) throws Exception {
                super.onResponse(data);
                activity.finish();
            }
        });
    }
}
